package com.xjtu.platform.admin.role;

import com.xjtu.platform.common.Result;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.Map;

@RestController
@RequestMapping("/admin/role")
public class RoleAPI {

    @Resource
    private RoleService roleService;

    @GetMapping("/getRoleInfo")
    public Result getRoleInfo(RoleDto roleDto){
        Map<String,Object> page = roleService.getRoleInfo(roleDto);

        return Result.success(page);
    }

    @PostMapping("/changeRoleWeb")
    public Result changRoleWeb(@RequestBody ChangeWebDto changeWebDto){
        boolean ok = roleService.changeWeb(changeWebDto);
        if(ok){
            return Result.success("修改成功！！！");
        }else {
            return Result.fail(Result.ERR_CODE_SYS,"系统维护中......");
        }
    }

    @PostMapping("/deleteRole")
    public Result deleteRole(@RequestBody DeleteDto deleteDto){
        boolean ok = roleService.deleteRole(deleteDto);
        if(ok){
            return Result.success("删除成功！！！");
        }else {
            return Result.fail(Result.ERR_CODE_SYS,"系统维护中......");
        }
    }
}
